import { defHttp } from '@/utils/http/axios';
import type {
  TagInfo,
  TagListParams,
  TagListResultModel,
  TagAddReq,
  TagEditReq,
} from './model/tagModel';

enum Api {
  List = '/api/admin/v1/tag/list',
  Create = '/api/admin/v1/tag/add',
  Update = '/api/admin/v1/tag/edit',
  Delete = '/api/admin/v1/tag/del',
  Info = '/api/admin/v1/tag/info',
}

export function getTagList(params?: TagListParams) {
  return defHttp.get<TagListResultModel>({
    url: Api.List,
    params,
  });
}

export function getTagInfo(id: number) {
  return defHttp.get<TagInfo>({
    url: Api.Info,
    params: { id },
  });
}

export function createTag(params: TagAddReq) {
  return defHttp.post<void>({
    url: Api.Create,
    params,
  });
}

export function updateTag(params: TagEditReq) {
  return defHttp.put<void>({
    url: Api.Update,
    params,
  });
}

export function deleteTag(id: number) {
  return defHttp.delete<void>({
    url: Api.Delete,
    params: { id },
  });
}
